﻿using System;
using HZ.DrugTrade.BLL;
using System.Text;
using System.Data;

using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.BLLFactory;
using HZ.DrugTrade.Model.Enum;

namespace HZ.DrugTrade.Web.Admin.SystemManage
{
    public partial class CompanyInfoMerge : BasePage
    {
        public CompanyInfoMerge()
        {
            this.ModuleNo = Module.系统管理.ToString();
            this.PageOperateType = OperateType.企业管理.ToString();
        }

  

        protected void Page_Load(object sender, EventArgs e)
        {

        
       
        }

      protected void HzButton1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbSourceCompanyName.Text) || string.IsNullOrEmpty(tbTarGetCompanyName.Text.Trim()))
            {
                HZ.Web.WebUtil.Alert("企业名称不能为空！");
                return;
            }
            if (string.IsNullOrEmpty(hidSourceID.Value) || string.IsNullOrEmpty(hidTargetID.Value))
            {
                HZ.Web.WebUtil.Alert("获取数据失败！");
                return;
            }
                IBLL_Company ic = Factory.BLL_Company();
                //int result = ic.MergeCompanyInfo(hidSourceID.Value, hidTargetID.Value,Convert.ToInt32(rblCompanyType.SelectedValue));
                //switch (result)
                //{
                //    case 0:
                //        HZ.Web.WebUtil.Alert("操作失败！");
                //        break;
                //    case 1:
                //        HZ.Web.WebUtil.Alert("操作成功！");
                //        break;
                //    case 2:
                //        break;
                //}
           
                   
        }

        /// <summary>
        /// 查询企业信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
      protected void btnSelectSource_Click(object sender, EventArgs e)
      {
          labSource.Text = SelectCompany(tbSourceCompanyName.Text.Trim(),1);
      }
      private string SelectCompany(string strCompanyName,int i)
     {
     
            BLL_Company bll = new BLL_Company();
               StringBuilder sb=new StringBuilder();
            int count = 0;
          //  DataTable dt = bll.GetCompanyInfoByWhereNOType(string.Format(" and TB_CompanyInfo.companyname='{0}' ", strCompanyName), 1, 0, out count);
          // if (dt.Rows.Count==1)
          //  {
          //     // sb.Append("[{CompanyName:\"" ++ "\",Address: \"" + dt.Rows[0]["Address"] + "\",TelNo:\"" + dt.Rows[0]["TelNo"] + "\",CompanyID:\"" + dt.Rows[0]["CompanyID"] + "\",BusinessCertificate:\"" + dt.Rows[0]["BusinessCertificate"] + "\"}]");
          // sb.Append("<table style=\"border:1px solid #ccc;\"><tr><td>企业名称</td><td>企业注册号</td><td>地址</td><td>电话</td><td>批准文号</td></tr><tr style='color:red'>");
          // sb.Append("<td>" +dt.Rows[0]["CompanyName"] + "</td>");
          //sb.Append("<td>" +dt.Rows[0]["CompanyID"] + "</td>");
          // sb.Append("<td>" +dt.Rows[0]["Address"] + "</td>");
          // sb.Append("<td>" +dt.Rows[0]["TelNo"] + "</td>");
          // sb.Append("<td>" +dt.Rows[0]["BusinessCertificate"] + "</td>");
          // sb.Append( "</td></tr></table>");
          // if (i == 1)
          //     hidSourceID.Value = dt.Rows[0]["CompanyID"].ToString();
          // else
          //     hidTargetID.Value = dt.Rows[0]["CompanyID"].ToString();
          // }
          //  else
          //  {
          //     sb.Append("<span style=\"color:red;font-size:12px\">查无此企业</span>");//暂无数据
          //  }

         return sb.ToString();
     }

      protected void BtnSelectTarget_Click(object sender, EventArgs e)
      {
          labTarget.Text=SelectCompany(tbTarGetCompanyName.Text.Trim(),2);
      }
    }
}

